package com.ip.student.api.client;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ip.common.constant.Result;
import com.ip.common.enums.CodeEnum;
import com.ip.user.models.common.annotation.RequiresPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import com.ip.student.models.service.IBaseSchoolService;
import com.ip.student.models.bo.BaseSchoolBO;
import com.ip.student.models.dto.BaseSchoolDTO;

/**
 * 学校信息控制器
 *
 * @author 张景奇
 * @Date 2025-10-29 09:02:17
 */

@RestController
@RequestMapping("/api/baseSchool")
@Slf4j
@Api(value = "BaseSchoolApiController",tags = "学校信息Api接口")
public class BaseSchoolApiController {

    @DubboReference
    private IBaseSchoolService baseSchoolService;

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    @RequiresPermission("base:class:query")
    public Result<BaseSchoolDTO> get(@RequestParam("id") Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }

        BaseSchoolDTO dto = baseSchoolService.selectById(id);

        return new Result<>(dto);
    }

   /* @ApiOperation(value = "学校信息列表",notes = "学校信息列表")
    @PostMapping("/queryPageList")
    @RequiresPermission("base:class:query")
    public Result<Page<BaseSchoolDTO>> queryPageList(BaseSchoolBO bo){
        Wrapper<BaseSchoolDTO> wrapper = new EntityWrapper<>();
        if (bo.getStartDate() != null){
            wrapper.ge("create_time", bo.getStartDate());
        }
        if (bo.getEndDate() != null){
            wrapper.le("create_time", bo.getEndDate());

        }
        Page<BaseSchoolDTO> page = new Page<>(bo.getPageNo(), bo.getPageSize());
        page = baseSchoolService.selectPage(page, wrapper);

        return new Result<>(page);
    } */
}